package com.unicdata.ai.demo_2af.service.impl;

/**
 * 日志服务实现类
 *
 * @author lhn
 * @date 2025/06/25 17:01
 * @since 1.0.0
 **/

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.unicdata.ai.demo_2af.common.entity.SysLog;
import com.unicdata.ai.demo_2af.mapper.SysLogMapper;
import com.unicdata.ai.demo_2af.service.SysLogService;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 日志服务实现类
 *
 * @author java-engineer
 */
@Service
public class SysLogServiceImpl extends ServiceImpl <SysLogMapper, SysLog> implements SysLogService {

    @Override
    public boolean saveLog(Long userId, String username, String operation, String method, String params,
                           Long time, String ip, Integer status, String errorMsg) {
        SysLog sysLog = new SysLog();
        sysLog.setUserId(userId);
        sysLog.setUsername(username);
        sysLog.setOperation(operation);
        sysLog.setMethod(method);
        sysLog.setParams(params);
        sysLog.setTime(time);
        sysLog.setIp(ip);
        sysLog.setStatus(status);
        sysLog.setErrorMsg(errorMsg);
        sysLog.setCreateTime(new Date());

        return save(sysLog);
    }
}